<template>
	<view>
		<view class="cu-card case" :class="isCard?'no-card':''">
			<view class="cu-item shadow">
				<view class="image imageac">
					<image :src="qjhc.value"
					 mode="widthFix"></image>
				</view>
			</view>
		</view>
		<view v-if="qjhc.tzgg" class="cu-bar bg-white solid-bottom margin-top">
			<view class="action">
				<text class="cuIcon-title text-blue"></text>{{qjhc.tzgg}}
			</view>
		</view>
		<uni-section v-if="qjhc.ankz" :title="tsxx" type="line">
			<view class="example" style="padding: 10px;">
				<!-- 基础表单校验 -->
				<uni-forms ref="valiForm" :rules="rules" :model="valiFormData" labelWidth="80px">
					<uni-forms-item label="身份证号" required name="zjhm">
						<uni-easyinput type="idcard" v-model="valiFormData.zjhm" placeholder="请输入身份证号" />
					</uni-forms-item>
				</uni-forms>
				<button :loading="loading" :disabled="loading" type="primary" @click="submit('valiForm')">提交</button>
			</view>
		</uni-section>
	</view>
</template>
<script>
	var _this;
	var vk = uni.vk;
	import uniForms from "@/pages_modules/components/uni-forms/uni-forms";
	import uniFormsItem from "@/pages_modules/components/uni-forms-item/uni-forms-item";
	export default {
		components:{uniForms,uniFormsItem},
		data() {
			// 页面数据变量
			return {
				logininfo:false,
				qjhc:{
					ankz:false
				},
				syimg:'https://mp-7c5f2fa7-1d2c-41f1-b3dd-1f45e490fd36.cdn.bspapp.com/cloudstorage/939374e2-cdad-4e6f-b088-9546464e94ea.jpg',
				tsxx:'',
				loading: false,
				// 校验规则
				rules: {
					zjhm: {
						rules: [{
							required: true,
							errorMessage: '身份证号错误'
						},{
							minLength: 18,
							maxLength: 18,
							errorMessage: '请输入正确的身份证',
						}]
					}
				},
				valiFormData:{zjhm:""},
				isCard: false,
				// init请求返回的数据
				data:{
					
				},
				// 表单请求数据
				form1:{
					
				},
				scrollTop:0,
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		// 监听 - 页面每次【加载时】执行(如：前进)
		async onLoad(options = {}) {
			vk = uni.vk;
			_this = this;
			//await this.getvkGlobalData()
			await this.getxxcjcxglobal()
		},
		// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快，会在页面进入动画完成前触发
		onReady(){
			
		},
		// 监听 - 页面每次【显示时】执行(如：前进和返回) (页面每次出现在屏幕上都触发，包括从下级页面点返回露出当前页面)
		onShow() {
			
		},
		// 监听 - 页面每次【隐藏时】执行(如：返回)
		onHide() {
			
		},
		// 监听 - 点击右上角转发时
		onShareAppMessage(options) {
			
		},
		// 函数
		methods: {
			getxsxx(sfzh){
				return vk.callFunction({
				  url: 'client/gsxy/jwc/pub/jwc-kqgl.getkqxsxx',
				  title:'请求中...',
				  data:{
					sfzh:sfzh
				  }
				}).then((data) => {
					if(data.info){
						_this.logininfo = true;
					}else{
						_this.logininfo = false;
					}}).catch((err) => {});
			},
			getxxcjcxglobal(){
				return vk.callFunction({
				  url: 'client/gsxy/globalDataCacheKye/pub/vk-global-data.findById',
				  title:'请求中...',
				  data:{
				    _id:'65a72652337a9f439486f272'
				  }
				}).then((data) => {
					_this.qjhc = data.info;
				}).catch((err) => {});
			},
			getvkGlobalData(){
				return vk.callFunction({
				  url: 'client/gsxy/jwc/pub/jwcapi.getvkGlobalDataByid',
				  title:'请求中...',
				  data:{
					  byid:'65443957337a9fe987d96e9d'
				  }
				}).then((data) => {
					_this.qjhc = data.info;
				}).catch((err) => {
				  
				});
			},
			submit(ref) {
				_this.loading = true
					this.$refs[ref].validate().then(async res => {
						await _this.getxsxx(res.zjhm)
						if(_this.logininfo){
							_this.loading = false;
							vk.navigateTo('/pages_modules/jwc/kqlist?zjhm='+_this.valiFormData.zjhm);
							_this.valiFormData.zjhm = '';
						}else{
							_this.valiFormData.zjhm = '';
							uni.showToast({
								title: '没有查询到相关信息',
								icon:'none'
							})
						}
						_this.loading = false;
					}).catch(err => {
						
						_this.valiFormData.zjhm = '';
						uni.showToast({
							title: err[0].errorMessage,
							icon:'none'
						})
						_this.loading = false;
					})
			}
		},
		// 监听器
		watch:{
			
		},
		// 计算属性
		computed:{
			
		}
	}
</script>
<style lang="scss" scoped>
	// .imageac{
	// 	width: 360px;
	// 	height: 166px;
	// }
	
</style>